import cn.edu.hbsi.dao.CarDao;
import cn.edu.hbsi.utils.GetSqlSessionUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Test;

public class testCar
{
    private SqlSession sqlSession = GetSqlSessionUtil.getSqlSession();
    private CarDao carDao = sqlSession.getMapper(CarDao.class);

    @Test
    public void testDeleteCarAndDriverByCId(){
        //删除id为4的汽车信息和其司机的信息
        if(carDao.deleteCarAndDriverByCId(4).intValue() == 2){
            System.out.println("删除成功");
        }else{
            System.out.println("删除失败");
        }
    }

    @Test
    public void testSelectCarAndDriverByCId(){
        //查询id为3的汽车的信息和其司机的信息
        System.out.println(carDao.selectCarAndDriverByCId(3));
    }

    @After
    public void destory(){
        sqlSession.commit();
        sqlSession.close();
    }
}
